define([
    "models/orders",
],function(OrderModel){

	function genOrderStatusSelectorUI (multicomboId, treeId) {
		return {
            view: "multicombo",
            id: multicomboId, label: "状态", labelAlign: "right",
            labelWidth: 40, width: 190, tagMode: false, optionWidth: 200,
            tagTemplate: function (values) {
                return (values.length ? values.length + "种状态已选择" : "");
            },
            suggest: {
                body: {
                    view: "tree", threeState: true, id: treeId,
                    template: "{common.icon()} {common.checkbox()} {common.folder()} #value#",
                    data: webix.copy(OrderModel.orderStatusTreeData),
                    on: {
                        onItemCheck: function (id) {
                            var ids = [];
                            this.data.eachLeaf(0, function (each) {
                                if (each.checked) {
                                    ids.push(each.id)
                                }
                            });
                            $$(multicomboId).setValue(ids)
                        }
                    }
                }
            }
        }
    };

	return {
        genOrderStatusSelectorUI:genOrderStatusSelectorUI
	};
});